#!/bin/bash
if [ -z "$TERM" ]; then
    echo " TERM not set"
    exit 1
fi 
r=$((${RANDOM} % 10000 + 10000 ))
echo "Starting reader and writer on port $r"
$TERM -e "java -classpath target/hh_0001_team01-1.0.jar ru.hh.school.client.ClientInputConsole $r" & 
CPID=$!
java -classpath target/hh_0001_team01-1.0.jar ru.hh.school.client.ClientChatConsole $r $1
kill $CPID 2> /dev/null 
